<?
require_once("../config/dbconn.php");require_once("../config/powercls.php");require_once("../config/pagecls.php");

//获取系统的第一个会员
if ($action=='query'){
	if (trim($username)!=''){
		$sql_hy="select * from {$db_prefix}users where username='".trim($username)."'";
		$rs_hy=$db->get_one($sql_hy);
		if (!$rs_hy['id']){
			echo "<script>alert('查询会员不存在');history.back();</script>";exit();
		}else{
			$gluser=$rs_hy['username'];
		}
	}
}else{
	$sql_hy="select * from {$db_prefix}users where ifnull(gluser,0)=0 and ifnull(tjuser,0)=0";
	$rs_hy=$db->get_one($sql_hy);
	if (!$gluser) $gluser=$rs_hy['username'];
}

$sqlhy="select * from {$db_prefix}users where username='$gluser'";
$rshy=$db->get_one($sqlhy);
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	
}
td{
font-size:12px;
}
-->
</style>

<link href="images/skin.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="17" height="29" valign="top" background="images/mail_leftbg.gif"><img src="images/left-top-right.gif" width="17" height="29" /></td>
    <td width="935" height="29" valign="top" background="images/content-bg.gif"><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="left_topbg" id="table2">
      <tr>
        <td height="31"><div class="titlebt">管理表</div></td>
      </tr>
    </table></td>
    <td width="16" valign="top" background="images/mail_rightbg.gif"><img src="images/nav-right-bg.gif" width="16" height="29" /></td>
  </tr>
  <tr>
    <td height="71" valign="middle" background="images/mail_leftbg.gif">&nbsp;</td>
    <td valign="top" bgcolor="#F7F8F9"><table width="100%" height="138" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="13" valign="top">&nbsp;</td>
      </tr>
      <tr>
        <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="nowtable">
                <tr>
                  <td align="center" class="left_bt2"><form name="form1" method="post" action="?action=query">
                    会员编号：
                    <label>
      <input name="username" type="text" id="username" size="10">
      </label>
                    昵称：
  <label>
  <input name="nickname" type="text" id="nickname" size="10">
  </label>
  <label>
  <input type="submit" name="Submit3" value="查询">
  </label>
                                    </form></td>
                </tr>
                <tr>
                  <td class="left_bt2">&nbsp;&nbsp;&nbsp;
				  <?
				  echo "[ ".$rshy['username']." ] 的管理下级";
				  ?>
				  <?
				 if ($rshy['gluser']&&($gluser!=$_SESSION['sys_username'])){
				  ?>
                    <input type="button" name="Submit" value="顶层" onClick="location.href='?gluser=<?=urlencode($_SESSION['sys_username'])?>'">
                    <input type="button" name="Submit2" value="上一层" onClick="location.href='?gluser=<?=urlencode($rshy['tjuser'])?>'">
				<?
				}
				?></td>
                </tr>
              </table></td>
            </tr>
            <tr>
              <td height="30"><table width="100%" height="60" border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <td height="30" align="center" bgcolor="#f2f2f2" >编号</td>
                  <td align="center" bgcolor="#f2f2f2" >用户名</td>
                  <td align="center" bgcolor="#f2f2f2" >昵称</td>
                  <td align="center" bgcolor="#f2f2f2" >级别</td>
                  <td align="center" bgcolor="#f2f2f2" >是否专卖店</td>
                  <td align="center" bgcolor="#f2f2f2" >报单人</td>
                  <td align="center" bgcolor="#f2f2f2" >推荐人</td>
                  <td align="center" bgcolor="#f2f2f2" >管理人</td>
                  <td align="center" bgcolor="#f2f2f2" >区位</td>
                  <td align="center" bgcolor="#f2f2f2" >注册时间</td>
                  <td height="30" align="center" bgcolor="#f2f2f2" >操作</td>
                  </tr>
	 <?
  $query='';
  if ($act=='query'){
  	
  }
  
  $sql="select count(id) as c  from {$db_prefix}users where gluser='".$gluser."'";
  if ($query!='') $sql.=$query;
  $rs=$db->get_one($sql);
  $page=new pagecls(20,intval($rs['c']));
  $sql="select * from {$db_prefix}users where gluser='".$gluser."'";
  if ($query!='') $sql.=$query;
  $sql.=" order by id asc limit {$page->pastnum},{$page->pagesize}";
  $result=$db->query($sql);
  while($rs=$db->fetch_array($result)){
  ?>
                <tr>
                  <td align="center"><?=$rs['id']?></td>
                  <td align="center"><a href="?gluser=<?=urlencode($rs['username'])?>"><?=$rs['username']?></a></td>
                  <td align="center">
                    <?=$rs['nickname']?>
                  </td>
                  <td align="center"><?=$hyrankary[$rs['rank']]?></td>
                  <td align="center" ><?=($rs['isdp']==1)?"是":"否"?></td>
                  <td align="center" ><?=$rs['bduser']?></td>
                  <td align="center" ><?=$rs['tjuser']?></td>
                  <td align="center" ><?=$rs['gluser']?></td>
                  <td align="center" ><?=$sysposary[$rs['pos']]?></td>
                  <td align="center" ><?=date("Y-m-d H:i:s",$rs['confirmtime'])?></td>
                  <td height="30" align="center" ><a href="user_view.php?id=<?=$rs['id']?>&pageno=<?=$page->pageno?>">查看</a></td>
                  </tr>
 <?
  }
  $db->free_result($result);
  ?>
              </table></td>
            </tr>
            
            <tr>
              <td height="30">&nbsp;</td>
            </tr>
            <tr>
              <td height="30" align="right">每页<?=$page->pagesize?>条 第<?=$page->pageno?>/<?=$page->pagenum?>页 共<?=$page->recnum?>条 <a href='?<?=$page->url?>1'><img src="image1/first.gif" border="0"></a>   <a href='?<?=$page->url.($page->pageno-1)?>'><img src="image1/back.gif" border="0"></a>  <a href='?<?=$page->url.($page->pageno+1)?>'><img src="image1/next.gif" border="0"></a>   <a href='?<?=$page->url.$page->pagenum?>'><img src="image1/last.gif" border="0"></a></td>
              </tr>
            <tr>
              <td height="30">&nbsp;</td>
            </tr>
          </table></td>
      </tr>
    </table></td>
    <td background="images/mail_rightbg.gif">&nbsp;</td>
  </tr>
  <tr>
    <td valign="middle" background="images/mail_leftbg.gif"><img src="images/buttom_left2.gif" width="17" height="17" /></td>
      <td height="17" valign="top" background="images/buttom_bgs.gif"><img src="images/buttom_bgs.gif" width="17" height="17" /></td>
    <td background="images/mail_rightbg.gif"><img src="images/buttom_right2.gif" width="16" height="17" /></td>
  </tr>
</table>

</body>
</html>
